package com.ssy.lingxi.product.controller.pc.warehouse;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.product.api.model.request.warehouse.InventoryListRequest;
import com.ssy.lingxi.product.api.model.request.warehouse.InventorySafetyUpdateRequest;
import com.ssy.lingxi.product.api.model.request.warehouse.QueryInventoryByItemNoRequest;
import com.ssy.lingxi.product.api.model.response.warehouse.InventoryListResponse;
import com.ssy.lingxi.product.api.model.response.warehouse.QueryInventoryByItemNoResponse;
import com.ssy.lingxi.product.service.InventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @menu 进销存-库存管理
 * @author wrc
 * @date 2020/7/20
 */
@Api(tags = "库存管理")
@RestController
@RequestMapping("/product")
public class InventoryController extends BaseController {
    @Resource
    InventoryService inventoryService;

    /**
     * 库存列表查询
     * @param request
     * @return
     */
    @GetMapping("/inventory/list")
    public Wrapper<PageData<InventoryListResponse>> inventoryList(InventoryListRequest request) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        return inventoryService.inventoryList(request,sysUser);
    }

    /**
     * 单个/批量调整安全库存
     * @param request
     * @return
     */
    @PostMapping("/inventory/safety/batch/update")
    public Wrapper<Void> inventorySafetyUpdate(@RequestBody InventorySafetyUpdateRequest request) {
        return inventoryService.inventorySafetyUpdate(request);
    }

    /**
    * 根据仓库名称和货号ID查询仓位库存
    * @author wrc
    * @date 2020/8/7
    */
    @GetMapping("/inventory/by/item/no")
    public Wrapper<QueryInventoryByItemNoResponse> queryInventoryByItemNo(QueryInventoryByItemNoRequest request) {
        return inventoryService.queryInventoryByItemNo(request);
    }

}
